package com.futureCloudMOM.core.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.futureCloudMOM.common.constant.GenConstants;
import com.futureCloudMOM.core.entity.FBaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Produce_TaskBillMaterial", description = "用料清单订单")
@TableName(value = "Produce_TaskBillMaterial")
public class ProduceTaskBillMaterial extends FBaseEntity implements Serializable {



    @NotNull(message="[任务Id]不能为空")
    @ApiModelProperty("任务Id")
    @TableField(value = "taskBillId")
    private Long taskBillId;

    @ApiModelProperty("序号")
    @TableField(value = "sortNo")
    private Long sortNo;

    @NotNull(message="[物料]不能为空")
    @ApiModelProperty("物料")
    @TableField(value = "materialId")
    private Long materialId;

    @NotNull(message="[BOMId]不能为空")
    @ApiModelProperty("BOMId")
    @TableField(value = "bomId")
    private Long bomId;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("BOM层级")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "bomlevel")
    private String bomlevel;

    @NotBlank(message="[折损率]不能为空")
    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("折损率")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "lossRate")
    private String lossRate;

    @NotBlank(message="[需求数量]不能为空")
    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("需求数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "calCount")
    private String calCount;

    @NotBlank(message="[实际数量/消耗]不能为空")
    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("实际数量/消耗")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "actCount")
    private String actCount;

    @NotBlank(message="[缺料数量]不能为空")
    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("缺料数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "lackCount")
    private String lackCount;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("投入数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "loadCount")
    private String loadCount;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("余料数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "cloutCount")
    private String cloutCount;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("不良数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "reworkQty")
    private String reworkQty;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("报废数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "scrapQty")
    private String scrapQty;

    @NotNull(message="[单位]不能为空")
    @ApiModelProperty("单位")
    @TableField(value = "unitId")
    private Long unitId;

    @NotNull(message="[状态 0未锁定 1已锁定 2已领料]不能为空")
    @ApiModelProperty("状态 0未锁定 1已锁定 2已领料")
    @TableField(value = "status")
    private Long status;

    /**
     * 根据工艺BOM子件获取实例
     *
     * @param technologyBomSub 工艺BOM子件
     * @return 实例
     */
    public static ProduceTaskBillMaterial getInstance(TechnologyBomSub technologyBomSub) {
        String[] ignoreProperties = GenConstants.F_BASE_ENTITY;
        ProduceTaskBillMaterial produceTaskBillMaterial = new ProduceTaskBillMaterial();
        BeanUtils.copyProperties(technologyBomSub, produceTaskBillMaterial, ignoreProperties);
        return produceTaskBillMaterial;
    }



}

